package com.yiwei.zxp.activity;

import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Spanned;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.allen.library.SuperButton;
import com.yiwei.zxp.R;
import com.yiwei.zxp.api.Api;
import com.yiwei.zxp.base.BaseActivity;
import com.yiwei.zxp.util.Network;
import com.yiwei.zxp.util.RxLifeUtil;
import com.yiwei.zxp.util.Spans;
import com.yiwei.zxp.util.ToastUtil;
import com.yiwei.zxp.util.Util;
import com.yiwei.zxp.view.ShopIdentitySuccessDilaog;
import com.yiwei.zxp.view.V19FrameLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by xsooy-pc on 17-12-8.
 */

public class ShopIdentityStatusActivity extends BaseActivity {
    @BindView(R.id.btn_back)
    ImageView btnBack;
    @BindView(R.id.txt_title)
    TextView txtTitle;
    @BindView(R.id.txt_right)
    TextView txtRight;
    @BindView(R.id.layout_title)
    V19FrameLayout layoutTitle;
    @BindView(R.id.img_status)
    ImageView imgStatus;
    @BindView(R.id.txt_tips)
    TextView txtTips;
    @BindView(R.id.btn_upload)
    SuperButton btnUpload;

    private Unbinder unbiner;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop_identity);
        initBar();
        unbiner = ButterKnife.bind(this);
        init();
    }


    private void init() {
        txtTitle.setText("店铺认证");
        String type = getIntent().getStringExtra("type");
        String fail_msg = getIntent().getStringExtra("fail_msg");
        switch (type) {
            case "-2":
                txtTips.setText("您还没有提交店铺认证资料");
                break;
            case "-1":
                imgStatus.setImageResource(R.mipmap.img_packet_fail);
//                txtTips.setText("很抱歉，您的店铺资料未通过审核\n未通过原因是资质认证照片不清晰");
                txtTips.setText(fail_msg);
                btnUpload.setVisibility(View.VISIBLE);
                break;
            case "0":
                imgStatus.setImageResource(R.mipmap.img_packet_ing);
                Spanned txtTip = Spans.with(this).font("店铺资料已提交后台审核，请耐心等待\n", getResources().getDimensionPixelSize(R.dimen.x30), 0xff000000).
                        font("您提交的信息会在1个工作日内审核完毕\n请注意关注通知", getResources().getDimensionPixelSize(R.dimen.x24), 0xff999999).
                        build();
                txtTips.setText(txtTip);

                break;
            case "1":
//                btnUpload.setVisibility(View.VISIBLE);
//                btnUpload.setText("添加商品");
                txtTips.setText("恭喜您，店铺资料审核通过\n赶紧去添加点商品吧");
                new ShopIdentitySuccessDilaog(this).setOnChooseListener(new ShopIdentitySuccessDilaog.OnChooseListener() {
                    @Override
                    public void onSuccess(String shop_name) {
                        Util.startActivity(ShopIdentityStatusActivity.this, GoodsAddActivity.class);
                        finish();
                    }

                    @Override
                    public void onLock() {

                    }
                }).show();
                imgStatus.setImageResource(R.mipmap.img_packet_success);
                break;
        }
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbiner.unbind();
        unbiner = null;
    }

    @OnClick({R.id.btn_back, R.id.btn_upload})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_back:
                finish();
                break;
            case R.id.btn_upload:
                Util.startActivity(this, SettingShopActivity.class);
                break;
        }
    }


}
